/*
 * DemoChannelListener.java
 *
 * Research In Motion Limited proprietary and confidential
 * Copyright Research In Motion Limited, 2011-2011
 */
package com.allkapps.bbmopenchat;

import com.allkapps.bbmopenchat.BaseScreen;

import net.rim.blackberry.api.bbm.platform.io.BBMPlatformChannelListener;
import net.rim.blackberry.api.bbm.platform.io.BBMPlatformConnection;
import net.rim.blackberry.api.bbm.platform.io.BBMPlatformData;
import net.rim.blackberry.api.bbm.platform.io.BBMPlatformIncomingJoinRequest;
import net.rim.blackberry.api.bbm.platform.profile.BBMPlatformContact;
import net.rim.blackberry.api.bbm.platform.profile.BBMPlatformContactList;

/**
 * This channel listener delegates the duties to a {@link BBMOpenChatConnectionListener}.
 * It leverages the inheritance properties of connections and channels to simplify
 * implementation.
 * <p>
 * A channel listener is required when creating a channel e.g. in {@link BBMBridge#createChannel(ChannelScreen)}.
 * The listener can also be accessed using {@link BBMPlatformConnection#getListener()}.
 *
 * *LOOK_HERE*
 *
 * @see {@link BBMBridge#createChannel(ChannelScreen)}
 * @see {@link BBMPlatformConnection#getListener()}
 * @see {@link net.rim.blackberry.api.bbm.platform.service.MessagingService}
 */
class BBMOpenChatChannelListener extends BBMPlatformChannelListener {

    private final BBMOpenChatConnectionListener _connectionListener;
    
    BBMOpenChatChannelListener(BaseScreen screen) {
        _connectionListener = new BBMOpenChatConnectionListener();
        _connectionListener.setScreen(screen);
    }

    /* (non-Javadoc)
     * @see net.rim.blackberry.api.bbm.platform.io.BBMPlatformConnectionListener#contactDeclined(net.rim.blackberry.api.bbm.platform.io.BBMPlatformConnection, net.rim.blackberry.api.bbm.platform.profile.BBMPlatformContact)
     */
    public void contactDeclined( BBMPlatformConnection connection, BBMPlatformContact contact ) {
        _connectionListener.contactDeclined( connection, contact );
    }

    /* (non-Javadoc)
     * @see net.rim.blackberry.api.bbm.platform.io.BBMPlatformConnectionListener#contactLeft(net.rim.blackberry.api.bbm.platform.io.BBMPlatformConnection, net.rim.blackberry.api.bbm.platform.profile.BBMPlatformContact)
     */
    public void contactLeft( BBMPlatformConnection connection, BBMPlatformContact contact ) {
        _connectionListener.contactLeft( connection, contact );
    }

    /* (non-Javadoc)
     * @see net.rim.blackberry.api.bbm.platform.io.BBMPlatformConnectionListener#contactsInvited(net.rim.blackberry.api.bbm.platform.io.BBMPlatformConnection, net.rim.blackberry.api.bbm.platform.profile.BBMPlatformContactList)
     */
    public void contactsInvited( BBMPlatformConnection connection, BBMPlatformContactList contactList ) {
        _connectionListener.contactsInvited( connection, contactList );

    }

    /* (non-Javadoc)
     * @see net.rim.blackberry.api.bbm.platform.io.BBMPlatformConnectionListener#contactsJoined(net.rim.blackberry.api.bbm.platform.io.BBMPlatformConnection, net.rim.blackberry.api.bbm.platform.profile.BBMPlatformContactList, java.lang.String, int)
     */
    public void contactsJoined( BBMPlatformConnection connection, BBMPlatformContactList contactList, String cookie, int type ) {
        _connectionListener.contactsJoined( connection, contactList, cookie, type );
    }

    /* (non-Javadoc)
     * @see net.rim.blackberry.api.bbm.platform.io.BBMPlatformConnectionListener#dataReceived(net.rim.blackberry.api.bbm.platform.io.BBMPlatformConnection, net.rim.blackberry.api.bbm.platform.profile.BBMPlatformContact, net.rim.blackberry.api.bbm.platform.io.BBMPlatformData)
     */
    public void dataReceived( BBMPlatformConnection connection, BBMPlatformContact sender, BBMPlatformData data ) {
        _connectionListener.dataReceived( connection, sender, data );
    }

    /* (non-Javadoc)
     * @see net.rim.blackberry.api.bbm.platform.io.BBMPlatformChannelListener#joinRequestCanceled(net.rim.blackberry.api.bbm.platform.io.BBMPlatformConnection, net.rim.blackberry.api.bbm.platform.io.BBMPlatformIncomingJoinRequest, int)
     */
    public void joinRequestCanceled( BBMPlatformConnection connection, BBMPlatformIncomingJoinRequest joinRequest, int reasonCode ) {
        _connectionListener.joinRequestCanceled( connection, joinRequest, reasonCode );
    }

    /* (non-Javadoc)
     * @see net.rim.blackberry.api.bbm.platform.io.BBMPlatformChannelListener#joinRequestReceived(net.rim.blackberry.api.bbm.platform.io.BBMPlatformConnection, net.rim.blackberry.api.bbm.platform.io.BBMPlatformIncomingJoinRequest, java.lang.String)
     */
    public void joinRequestReceived( BBMPlatformConnection connection, BBMPlatformIncomingJoinRequest joinRequest, String cookie ) {
        _connectionListener.joinRequestReceived( connection, joinRequest, cookie );
    }
}
